﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UtilLib;
using UtilPublic.ServerLoger;

namespace ConfClient
{
    //全局配置
    public class GlobalConfigExt
    {
        public int GlobalId;
        public ConfigGlobal SettBase;
        public string Value;
        public bool ValueBool;
        public int ValueInt;
        public long ValueLong;
        public float ValueFloat;
        public List<string> ValueListString;
        public List<int> ValueListInt;
        public List<float> ValueListfloat;
        public List<List<int>> ValueListListInt;
        public GlobalConfigExt(ConfigGlobal v)
        {
            GlobalId = v.GlobalId;
            SettBase = v;
            Value = v.Value;
            ValueBool = Value.ToBool();
            ValueInt = Value.ToInt();
            ValueLong = Value.ToLong();
            ValueFloat = Value.ToFloat();
            ValueListString = Value.ToListString(Conf.ConfListSeparator);
            ValueListInt = Value.ToListInt(Conf.ConfListSeparator);
            ValueListfloat = Value.ToListFloat(Conf.ConfListSeparator);
            ValueListListInt = Value.ToListListInt(Conf.ConfDictionarySeparator1, Conf.ConfDictionarySeparator2);
        }
    }
    // 房间
    public class ConfigRoomExt
    {
        public long Id;
        public ConfigRoom SettBase;
        public List<EInitType> Inits = new List<EInitType>(); // 触发事件列表
        public List<EActType> Acts = new List<EActType>(); // 提供事件列表
        public List<EResourceType> Resources = new List<EResourceType>(); // 提供资源列表
        public ConfigRoomExt(ConfigRoom v)
        {
            Id = v.Id;
            SettBase = v;
            foreach (var item in SettBase.Inits)
            {
                if (item.IsNullOrEmpty())
                {
                    continue;
                }
                if (!item.TryParseEnum(out EInitType data))
                {
                    loger.Error($"ConfigRoom 触发事件列表 枚举错误 {item}");
                    continue;
                }
                Inits.Add(data);
            }
            foreach (var item in SettBase.Acts)
            {
                if (item.IsNullOrEmpty())
                {
                    continue;
                }
                if (!item.TryParseEnum(out EActType data))
                {
                    loger.Error($"ConfigRoom 提供事件列表 枚举错误 {item}");
                    continue;
                }
                Acts.Add(data);
            }
            foreach (var item in SettBase.Resources)
            {
                if (item.IsNullOrEmpty())
                {
                    continue;
                }
                if (!item.TryParseEnum(out EResourceType data))
                {
                    loger.Error($"ConfigRoom 提供资源列表 枚举错误 {item}");
                    continue;
                }
                Resources.Add(data);
            }
        }
    }

}